package org.gd.hellojaxb.privatzvit;

import org.gd.hellojaxb.utils.Marshall;
import org.gd.hellojaxb.utils.MarshallProperties;

import javax.xml.bind.annotation.*;

/**
 *
 * @author Malakhov
 */
@XmlRootElement(name = "ORG")
@XmlAccessorType(XmlAccessType.NONE)
public class Organization {

    @XmlElement(name = "ID")
    private String id;
    @XmlElement(name = "FIRM_NAME")
    private String firmName;
    @XmlElement(name = "FIRM_EDRPOU")
    private String edrpou;
    @XmlElement(name = "ID_EKB")
    private String ekbId;
    @XmlElement(name = "DRFO")
    private String drfo;

    public Organization() {
        this.id = "";
        this.firmName = "";
        this.edrpou = "";
        this.ekbId = "";
        this.drfo = "";
    }

    @SuppressWarnings("unused")
    public Organization(String firmName, String edrpou, String ekbId, String drfo) {
        this();
        this.firmName = firmName;
        this.edrpou = edrpou;
        this.ekbId = ekbId;
        this.drfo = drfo;
    }

    public String getDrfo() {
        return drfo;
    }

    public void setDrfo(String drfo) {
        this.drfo = drfo;
    }

    public String getEdrpou() {
        return edrpou;
    }

    public void setEdrpou(String edrpou) {
        this.edrpou = edrpou;
    }

    public String getEkbId() {
        return ekbId;
    }

    public void setEkbId(String ekbId) {
        this.ekbId = ekbId;
    }

    public String getFirmName() {
        return firmName;
    }

    public void setFirmName(String firmName) {
        this.firmName = firmName;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String toXml() {
        StringBuilder sb = new StringBuilder();
        sb.append("<ORG>");
        sb.append("<ID>").append(getId()).append("</ID>");
        sb.append("<DRFO>").append(getDrfo()).append("</DRFO>");
        sb.append("<FIRM_EDRPOU>").append(getEdrpou()).append("</FIRM_EDRPOU>");
        sb.append("<FIRM_NAME>").append(getFirmName()).append("</FIRM_NAME>");
        sb.append("<ID_EKB>").append(getEkbId()).append("</ID_EKB>");
        sb.append("</ORG>");
        return sb.toString();
    }

    @Override
    public String toString() {
        try {
            return Marshall.getInstance().marshal(this, MarshallProperties.FORMATTED_OUTPUT);
        } catch (Throwable e) {
            return super.toString();
        }
    }
}
